package com.dongdong.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdong.data.Page;
import com.dongdong.mapper.TbSellerMapper;
import com.dongdong.pojo.TbSeller;
import com.dongdong.pojo.TbSellerExample;
import com.dongdong.service.SellerService;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
@org.springframework.stereotype.Service
public class SellerServiceImpl implements SellerService {
    @Autowired
    private TbSellerMapper tbSellerMapper;

    @Override
    public List<TbSeller> selectInfo(TbSeller tbSeller) {
        TbSellerExample tr = new TbSellerExample();
        tr.createCriteria().andNameLike(tbSeller.getName()).andNickNameLike(tbSeller.getNickName()).andStatusLike(tbSeller.getStatus());
        return tbSellerMapper.selectByExample(tr);
    }

    @Override
    public TbSeller selectBysellerId(String sellerId) {
        return tbSellerMapper.selectByPrimaryKey(sellerId);
    }

    @Override
    public int addSellerInfo(TbSeller tbSeller) {
        return tbSellerMapper.insertSelective(tbSeller);
    }

    @Override
    public TbSeller selectByPname(String username) {
        TbSellerExample tse = new TbSellerExample();
        tse.createCriteria().andSellerIdEqualTo(username);
        List<TbSeller> sellers = tbSellerMapper.selectByExample(tse);
        return sellers.size()>0?sellers.get(0):null;

    }

    @Override
    public boolean selectSellerId(String sellerId) {

        TbSeller sellers = tbSellerMapper.selectBySellerId(sellerId);
        return sellers == null?true:false;

    }

    @Override
    public int updateStatus(TbSeller tbSeller) {
        return tbSellerMapper.updateStatus(tbSeller);
    }
}
